package com.example.dellpc.myapplication;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

/**
 * Created by dellpc on 2016/8/11.
 */
public class SlidingMenuFragment extends Fragment {

    private ListView listView;
    private static String[] titles = new String[]{"头条", "NBA", "英超", "西甲", "奥运", "意甲"};

    private Button button;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v= inflater.inflate(R.layout.drawlayout,container,false);

        listView= (ListView) v.findViewById(R.id.listview);
        ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.support_simple_spinner_dropdown_item,titles);
        listView.setAdapter(adapter);
        return v;
    }

    /**
     * 防止预加载
     * @param isVisibleToUser
     */
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            //fragment可见时执行加载数据或者进度条等

        } else {
            //不可见时不执行操作
        }
    }
}
